<template>
	<div class="answer_page">
		<div class="answer_left">
			<!-- {{currentQuest}} -->
			<Instruction :currentItem="currentItem" @onStart="onStart" v-if="Instvisible" />
			<optionAnswer v-else :currentItem="currentQuest" />
		</div>
		<!-- <div class="answer_right" v-if="toAdminInstruction != ''">
			{{currentQuest.toAdminInstruction}}
		</div> -->
	</div>
	
</template>

<script lang="ts" setup>
	import { ref, watch, nextTick,onMounted,computed,render } from 'vue';
	import { useRoute } from 'vue-router';
	import { Modal } from 'ant-design-vue';
	import { useWorkBenches, useWebstock } from '@/store';
	import { getItemAllInfo } from "@/api/item";
	import Instruction from "./component/Instruction.vue";
	import optionAnswer from "./component/optionAnswer.vue";
	
	
	const ROUTE = useRoute();
	const Workben = useWorkBenches();
	const webstockStore = useWebstock();
	
	const currentQuest = computed(()=> Workben.$state.currentQuest);
	const currentItem = ref({});
	const Instvisible = computed(()=> Workben.$state.Instvisible);
	// const toAdminInstruction = ref('');
	
	const onStart = ()=>{
		const { userItemRecordId, itemId } = currentQuest.value;
		console.log(currentQuest.value)
		// console.log({ messageCode:'8',userId: localStorage.getItem('currentId'), userItemRecordId,itemId  })
		webstockStore.sendMessage({ messageCode:'2',userId: localStorage.getItem('currentId'), userItemRecordId,itemId  });
		// Modal.confirm({
		//     content: `您确定开始测评吗？`,
		//     onOk() {
		// 		localStorage.setItem('Instvisible',false);
		// 		Instvisible.value = false;
		//     },
		//     // eslint-disable-next-line @typescript-eslint/no-empty-function
		//     onCancel() {},
		// });
	};
	
	// watch(()=>currentQuest.value,()=>{
	// 	console.log('dd',currentQuest.value);
	// },{ immediate:true });
	
	onMounted(async ()=>{
		const { id } = ROUTE.params;
		const res = await getItemAllInfo({ itemId:id });
		if(!res) return;
		webstockStore.sendMessage({ messageCode:'6',userId: localStorage.getItem('currentId') });
		// console.log({ messageCode:'6',userId: localStorage.getItem('currentId') });
		currentItem.value = res;
		// console.log(currentQuest.value)
		// if(currentQuest.value.sort){
		// 	Instvisible.value = false;
		// }else{
		// 	Instvisible.value = true;
		// }
		// console.log(currentQuest.value);
		// localStorage.setItem('currentItem', JSON.stringify(res));
		// if(!localStorage.getItem('currentId')){
		// 	localStorage.setItem('currentSort', 0);
		// }
		// if(localStorage.getItem('Instvisible')){
			// Instvisible.value = true;
		// }
		// Workben.getpopList(true);
		// const res = await webstockStore.sendMessage({ messageCode:'2',userId: 1 });
		// Workben.getpopList(true);
	});
</script>

<style lang="less" scoped>
	.answer_page{
		display: flex;
		justify-content: space-between;
		padding: 50px;
		height: calc(100vh - 30px);
		width: 100%;
	}
	.answer_left{
		flex:1;
		// border-right: 1px dashed #ccc;
		display: flex;
		flex-direction: column;
	}
	// .answer_right{
	// 	width: 30%;
	// 	font-size: 18px;
	// 	text-indent: 2em;
	// 	padding: 10px;
	// }
	
</style>